package ${package.Parent}.factory;

import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.wang.cloud.common.core.api.ApiResult;
import ${package.Parent}.client.${entity?replace('Entity', 'Client')};
import ${package.Parent}.domain.co.${entity?replace('Entity', '')}AddCo;
import ${package.Parent}.domain.co.${entity?replace('Entity', '')}PageCo;
import ${package.Parent}.domain.co.${entity?replace('Entity', '')}UpdateCo;
import ${package.Parent}.domain.vo.${entity?replace('Entity', '')}PageVo;
import ${package.Parent}.domain.vo.${entity?replace('Entity', '')}Vo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


/**
 * <p>
 * ${table.comment!} 回退工厂
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Slf4j
@Component
public class ${entity?replace('Entity', 'ClientFallbackFactory')} implements FallbackFactory<${entity?replace('Entity', 'Client')}> {

    @Override
    public ${entity?replace('Entity', 'Client')} create(Throwable cause) {
        return new ${entity?replace('Entity', 'Client')}() {

            @Override
            public ApiResult<PageDTO<${entity?replace('Entity', 'PageVo')}>> page(${entity?replace('Entity', 'PageCo')} pageCo) {
                log.error("服务繁忙!{}", cause.getMessage());
                return ApiResult.failed("服务繁忙");
            }

            @Override
            public ApiResult<${entity?replace('Entity', 'Vo')}> page(Long id) {
                log.error("服务繁忙!{}", cause.getMessage());
                return ApiResult.failed("服务繁忙");
            }

            @Override
            public ApiResult<Long> add(${entity?replace('Entity', 'AddCo')} addCo) {
                log.error("服务繁忙!{}", cause.getMessage());
                return ApiResult.failed("服务繁忙");
            }

            @Override
            public ApiResult update(${entity?replace('Entity', 'UpdateCo')} updateCo) {
                log.error("服务繁忙!{}", cause.getMessage());
                return ApiResult.failed("服务繁忙");
            }

            @Override
            public ApiResult del(Long id) {
                log.error("服务繁忙!{}", cause.getMessage());
                return ApiResult.failed("服务繁忙");
            }
        };
    }
}
